package bigbrother;

import bigbrother.core.IrcBotCore;
import bigbrother.log.Log;
import bigbrother.log.LogImpl;

import java.io.File;

/**
 * @author Hans Haggstrom
 */
public class IrcBotContextImpl
        implements IrcBotContext
{

    //======================================================================
    // Private Fields

    private final IrcBotCore myIrcBotCore;
    private final Log myLog;

    //======================================================================
    // Public Methods

    //----------------------------------------------------------------------
    // Constructors

    public IrcBotContextImpl( final IrcBotCore ircBotCore, final File logFileStorageDirectory )
    {
        ParameterChecker.checkNotNull( ircBotCore, "ircBotCore" );

        myIrcBotCore = ircBotCore;

        myLog = new LogImpl( logFileStorageDirectory );
    }

    //----------------------------------------------------------------------
    // IrcBotContext Implementation


    public Log getLog()
    {
        return myLog;
    }


    public void sendMultilineMessage( final String message, final String target )
    {
        // Split message into lines and send it
        final String[] lines = message.split( "\\n" );
        for ( String line : lines )
        {
            myIrcBotCore.sendMessage( target, line );
        }
    }


    public IrcBotCore getCore()
    {
        return myIrcBotCore;
    }

}
